$(function(){
	 var rowId=localStorage.getItem("rowId");
	 getSysParamsById(rowId);
	 localStorage.removeItem("rowId");
});

function getSysParamsById(id){
	$.ajax({
		url:webUrl+'sysParams/getSysParamsById.do',
		type:'post',
		data:{id:id}
	}).done(function(data){
		var aa=eval("("+data.bo+")");
		var result=aa;
		//alert(JSON.stringify(aa));
		if(result.paramLevel==0){
			$("#typeCode").val(result.typeCode);
		}else{
			$("#typeCode").val(result.paramKey);
		}
		$("#paramLevel").val(parseInt(result.paramLevel)+1);
	});
}

function submitParam(){
	var json={};
    json = $("#addDataFormParam").serializeObject();
	if(checknull("paramValue")){
		//alert(JSON.stringify(json));
		addEntitySysParam(json);
	}
}

function addEntitySysParam(obj){
	obj=JSON.stringify(obj);
	$.ajax({
		url: webUrl+'sysParams/addEntitySysParam.do',
		type:'post',
		data:{param:obj}
	}).done(function(data){
		$('.main_panel').load(webUrl+"public/page/sysParams/params.html");
	});
}

$("ul.tabtit").on("click",function(event){
	$('.main_panel').load(webUrl+"public/page/sysParams/params.html");
});

$.fn.serializeObject = function()    
{    
   var o = {};    
   var a = this.serializeArray();    
   $.each(a, function() {    
       if (o[this.name]) {    
           if (!o[this.name].push) {    
               o[this.name] = [o[this.name]];    
           }    
           o[this.name].push(this.value || '');    
       } else {    
           o[this.name] = this.value || '';    
       }    
   });    
   return o;    
};  